package com.waves.task.domain.enums;

/**
 * @author dlw
 * @date 2024/09/28
 **/

import com.waves.core.constant.redis.TaskRedisKey;
import com.waves.core.constant.redis.UserRedisKey;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;

@AllArgsConstructor
@Getter
public enum RedisSetTypeEnum {
    TASK_LIKED(1, TaskRedisKey.TASK_LIKED_SET,"点赞"),
    TASK_COLLECTED(2, TaskRedisKey.TASK_COLLECTED_SET, "收藏"),
    USER_FOLLOW(3, UserRedisKey.USER_FOLLOW_SET,"关注"),
    USER_FOLLOWED(4, UserRedisKey.USER_FOLLOWED_SET, "被关注"),
    TASK_COMMENT_LIKED(5, TaskRedisKey.TASK_COMMENT_LIKED_SET, "帖子评论点赞")
    ;

    private final Integer code;
    private final String key;
    private final String desc;

    public static Optional<RedisSetTypeEnum> getEnumByCode(Integer code) {
        return Arrays.stream(RedisSetTypeEnum.values())
                .filter(f -> Objects.equals(f.getCode(), code))
                .findFirst();
    }
}
